package com.woniu.smart.controller;

import com.github.pagehelper.PageInfo;
import com.woniu.smart.dto.FollowDTO;
import com.woniu.smart.service.FollowService;
import com.woniu.smart.util.Result;
import com.woniu.smart.vo.FollowVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *
 * @description：TODO
 *
 * @author     ：mmzs
 * @date       ：2022/10/25 9:23
 */
@RestController
@RequestMapping("follows")
public class FollowController {
    @Autowired
    private FollowService followService;

    /**
     * 查全部
     * @param followDTO
     * @return
     */
    @PostMapping
    public Result selAll(@RequestBody FollowDTO followDTO){
        List<FollowVO> list = followService.selectAllByCustomerId(followDTO);
        PageInfo<FollowVO> pageInfo = new PageInfo<>(list);
        String s = followService.selCustomentName(followDTO);
        return Result.ok().data("list",pageInfo).data("customerName",s);
    }
    /**
     * 添加
     * @param followVO
     * @return
     */
    @PostMapping("add")
    public Result add(@RequestBody FollowVO followVO){
        int i = followService.insertSelective(followVO);
        return Result.ok();
    }
    /**
     * 详情
     * @param followId
     * @return
     */
    @GetMapping("{followId}")
    public Result selByCustomerId(@PathVariable Long followId){
        FollowVO followVO = followService.selectByFollowId(followId);
        return Result.ok().data("followVO",followVO);
    }
}
